#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QLineEdit>
#include <QtSerialPort/QSerialPort>
#include <QTimer>
#include <QThread>

#include "MyThread.h"


QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private:
    void CustomBaudSet();

    void TimerTimeout();

    void SerialSendData();

private slots:
    void slotBaudSelect();

    void on_btnSend_clicked();

    void on_btnOpenSerialPort_clicked();

    void serial_readyRead();

    void on_btnClearRecv_clicked();

    void on_btnClearSend_clicked();

    void on_checkBoxAutoSend_stateChanged(int arg1);

    void on_btnStopShow_clicked();

private:
    Ui::Widget *ui;


    bool m_isOpen = false; // 串口是否已打开
    bool m_stopShow = false; // 停止显示标记
    QSerialPort *m_serial;
    QLineEdit* m_pBaudLineEdit;
    QTimer* m_timer;

    MyThread* m_autoSendThread;
};
#endif // WIDGET_H
